package com.java.tutorials.jdk7.diamondoperator;
import java.util.ArrayList;
/**
 * Created by xuzhike on 2016/1/23.
 * http://www.java2s.com/Code/Java/JDK-7/UsingtheSafeVarargsAnnotation.htm
 * Using the @SafeVarargs Annotation
 */
public class SafeVarargsAnnotationTest {
    public static void main(String[] args) {
        ArrayList<Integer> a1 = new ArrayList<>();
        a1.add(new Integer(1));
        a1.add(2);
        ArrayList<Float> a2 = new ArrayList<>();
        a2.add(new Float(3.0));
        a2.add(new Float(4.0));
        displayElements(a1, a2, 12);

    }

    @SafeVarargs
    public static <T> void displayElements(T... array) {
        for (T element : array) {
            System.out.println(element.getClass().getName() + ": " + element);
        }
    }
}
